package com.acwing.partition12;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/28 9:57
 */
public class AC1183电力 {

    private static final int N = 10010, M = 30010;
    private static int[] h = new int[N], e = new int[M], ne = new int[M];

    private static int n = 0, m = 0, idx = 0, timestamp = 0, ans = 0, root = -1;
    private static int[] dfn = new int[N], low = new int[N];

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        while (true) {
            String[] s = reader.readLine().trim().split("\\s+");
            n = Integer.parseInt(s[0]);
            m = Integer.parseInt(s[1]);
            if (n == 0 && m == 0) break;
            for (int i = 0; i < N; i++) {
                h[i] = -1;
                dfn[i] = 0;
            }
            idx = ans = timestamp = 0;
            for (int i = 0; i < m; i++) {
                s = reader.readLine().split(" ");
                int a = Integer.parseInt(s[0]), b = Integer.parseInt(s[1]);
                add(a, b);
                add(b, a);
            }
            int cnt = 0;
            //统计连通块的数量
            for (root = 0; root < n; root++) {
                if (dfn[root] == 0) {
                    cnt++;
                    tarjan(root);
                }
            }
            writer.write((ans + cnt - 1) + "\n");
        }
        writer.flush();
    }

    private static void tarjan(int u) {
        dfn[u] = low[u] = ++timestamp;
        //当前块内，已经可以分出来的子树的个数
        int cnt = 0;
        for (int i = h[u]; i != -1; i = ne[i]) {
            int v = e[i];
            if (dfn[v] == 0) {
                tarjan(v);
                low[u] = Math.min(low[u], low[v]);
                if (dfn[u] <= low[v]) cnt++;
            } else low[u] = Math.min(low[u], dfn[v]);
        }
        if (u != root) cnt++;
        ans = Math.max(ans, cnt);
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}
